package tests;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import primitive3D.Triangle;
import rayCaster.Ray;

public class TestTriangle {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		Point3d a = new Point3d(1,2,0);
		Point3d b = new Point3d(1,1,0);
		Point3d c = new Point3d(1,1,1);
		Triangle t = new Triangle(a,b,c);
		System.out.println(t);

		System.out.println("Los puntos del triangulo son: ");
		Point3d[] puntos = t.getPoints();
		for( int i=0; i < 3; i++ ) {
			System.out.print(puntos[i] + " ");	
		}
		System.out.println();
		
		System.out.println("Los vectores asociados al triangulo son: ");
		System.out.println(t.getFirstVector() + " y " + t.getSecondVector());
		
		Vector3d normal = t.getVecNormal();
		System.out.println("Vector normal al triangulo: " + normal);
		
		double area = t.area();
		System.out.println("Area del triangulo: " + area);
		
		// Test de interseccion
		Point3d origin = new Point3d(1,1,0);
		Point3d dir = new Point3d(2,2,0);
		Ray r = new Ray(origin,dir);
		System.out.println(r);
		
		Point3d[] pts = new Point3d[2];
		pts[0] = new Point3d();
		pts[1] = new Point3d();
		
		if( t.intersects(r, pts) == 1 ) {
			System.out.print("Punto de interseccion entre el triangulo ");
			System.out.println("y el rayo: " + pts[0]);
		}
	}

}
